package com.rzjm.api.netty.water.entity;

import cn.hutool.core.util.StrUtil;
import com.rzjm.api.netty.water.constant.SendRtEnum;
import lombok.Data;

/**
 * @author WangWT
 * @Description: 向设备发送数据
 * @date 2023/2/24 16:24
 */
@Data
public class SendObjectData {
    private Integer rt;
    private Long tag;
    private Object v1;
    private Object v2;
    private Object v3;
    private Object v4;
    private Object v5;
    private Object v6;
    private Object v7;

    @Override
    public String toString() {
        String desc = getDesc();
        if (StrUtil.isBlank(desc)) {
            desc = "SendData{" +
                "rt=" + rt +
                ", tag=" + tag +
                ", v1=" + v1 +
                ", v2=" + v2 +
                ", v3=" + v3 +
                ", v4=" + v4 +
                ", v5=" + v5 +
                ", v6=" + v6 +
                ", v7=" + v7 +
                '}';
        }
        return desc;
    }

    private String getDesc() {
        try {
            if (rt == null) {
                return null;
            }
            SendRtEnum sendRtEnum = SendRtEnum.getByRt(rt);
            if (sendRtEnum == null) {
                return null;
            }
            StringBuffer data = new StringBuffer();
            data.append(sendRtEnum.getDescription()).append(": {");
            switch (sendRtEnum) {
                default:
                    break;

            }
            data.append("}");
            return data.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
